#pragma once

class CMpqHandler : public Singleton<CMpqHandler>
{
	struct MPQEntry
	{
		std::string archiveName;
		HANDLE archiveHandle;
	};

	std::map<std::string, HANDLE> m_archives;
	std::map<std::string, HANDLE> m_patches;
	std::list<MPQEntry> mArchives;
	std::string m_szLocale;
	ui32 m_build;
	void SortArchives();
public:
	CMpqHandler();
	bool Init();

	std::string GetLocale() { return m_szLocale; }

	HANDLE GetFile(std::string szFile, FILE** pOut, std::string szArchive = "");
	ui32 GetBuild() { return m_build; }
};

#define sMpqHandler (*CMpqHandler::GetInstance())